import itertools
from pyalgotrade.optimizer import server

from pyalgotrade.barfeed.csvfeed import GenericBarFeed
from pyalgotrade.bar import Frequency

#import MyRSIStrategy

def parameters_generator():
    instrument = ["Sinopec"]
    entrySMA = range(162, 165)
    exitSMA = range(7, 10)
    rsiPeriod = range(2, 5)
    overBoughtThreshold = range(89, 92)
    overSoldThreshold = range(9, 12)
    return itertools.product(instrument, entrySMA, exitSMA,
                            rsiPeriod, overBoughtThreshold,
                            overSoldThreshold)

# The if __name__ == '__main__' part is necessary if running on Windows.
if __name__ == '__main__':
    # Load the feed from the CSV files.
    feed = GenericBarFeed(Frequency.DAY, None, None)  
    feed.addBarsFromCSV("Sinopec", "./600028SH.new.csv")
    # Run the server.
    server.serve(feed, parameters_generator(), "localhost", 9090)